#include "GamePlayer.h"
#include "Card.h"
static GamePlayer *s_player;

GamePlayer* GamePlayer::getInstance()
{
	if (s_player == NULL) {
		s_player = new GamePlayer();
	}
	return s_player;
}

GamePlayer::GamePlayer(void)
{
}


GamePlayer::~GamePlayer(void)
{
}
bool GamePlayer::addCardMgr(Card *tCard)
{
	//m_Card_Mgr.pushBack(tCard);
	//memcpy(tCard,m_First_Cards,PAOHUZI_SIGNAL_BLOCK_NUM*sizeof(int));
	memcpy(&m_First_Cards,tCard,sizeof(int)*PAOHUZI_SIGNAL_BLOCK_NUM);

	return true;
}
void GamePlayer::setPomeloReponse(PomeloReponse* tRes)
{
	m_res_data=tRes;
	init();
}

bool  GamePlayer::init()
{
	json_t *tableinfo = json_object_get(m_res_data->docs,"tableInfo");
	CheckCondition(tableinfo,false);
	int id = json_integer_value(json_object_get(tableinfo,"id"));


	json_t *playerarray=json_object_get(m_res_data->docs,"myCardsIndex");
	//std::string pchar=json_dumps(playerarray,21);
	for(int i=0;i<json_array_size(playerarray)&&i<PAOHUZI_MAX_CARD_INDEX;i++)
	{
		int card_value=json_integer_value(json_array_get(playerarray,i));

		m_First_Cards[i]=card_value;

	}
	return true;
}
int* GamePlayer::getCardResource()
{

	return m_First_Cards;
}